﻿
using BCGM.MedicalWisdom.IServices;
using BCGM.MedicalWisdom.Model.Models;
using BCGM.MedicalWisdom.Services.BASE;
using BCGM.MedicalWisdom.Repository.BASE;
using System.Threading.Tasks;
using System.Collections.Generic;
using BCGM.MedicalWisdom.Model.ViewModels.Order;
using SqlSugar;
using AutoMapper;

namespace BCGM.MedicalWisdom.Services
{
    public class DrugOrderItemServices : BaseServices<DrugOrderItem>, IDrugOrderItemServices
    {
        private readonly IBaseRepository<DrugOrderItem> _dal;
        private readonly IMapper _mapper;
        public DrugOrderItemServices(IBaseRepository<DrugOrderItem> dal, Mapper mapper)
        {
            this._dal = dal;
            base.BaseDal = dal;
            this._mapper = mapper;
        }
        /// <summary>
        /// sql语句药品订单详情显示
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public async Task<List<DrugOrderItemOutputDto>> GetOrderItemSql(int orderId)
        {
            string sql = $"select * from DrugOrderItem where OrderId='{orderId}'";
            var list = await base.BaseDal.QuerySql(sql);
            var drugOrdersItem = _mapper.Map<List<DrugOrderItemOutputDto>>(list);
            return drugOrdersItem;
        }
    }
}